<div id="crop_image_monitor"></div>
<div id="toolbar-box">
  <div class="t">
    <div class="t">
      <div class="t"></div>
    </div>
  </div>
  <div class="m">
    <div id="toolbar" class="toolbar">
        <table class="toolbar"><tbody><tr>
                <td id="toolbar-save" class="button"><a class="toolbar" onClick="javascript: submitbutton('crop'); return false;" href="javascript:void(0);"> <span title="crop" class="icon-32-save"> </span> crop </a> </td>
        	<td id="toolbar-save" class="button"><a class="toolbar" onClick="javascript: submitbutton('save'); return false;" href="javascript:void(0);"> <span title="Save" class="icon-32-save"> </span> Save </a> </td>
	        <td id="toolbar-cancel" class="button"><a class="toolbar" onClick="javascript: submitbutton('cancel'); return false;" href="javascript:void(0);"> <span title="Cancel" class="icon-32-cancel"> </span> Cancel </a> </td>
        </tr></tbody></table>
    </div>
    <div class="header icon-48-user">chỉnh sửa nội dung tin tức</div>
    <div class="clr"></div>
  </div>
  <div class="b">
    <div class="b">
      <div class="b"></div>
    </div>
  </div>
</div>
<div class="clr"></div>
<div id="submenu-box">
  <div class="t">
    <div class="t">
      <div class="t"></div>
    </div>
  </div>
  <div class="m">
    <ul id="submenu">
      <li> <a class="active" href="<?php echo $this->Html->url(array('controller'=>'news', 'action'=>'index')); ?>">Tin tức</a> </li>
      <li> <a href="<?php echo $this->Html->url(array('controller'=>'news_categories', 'action'=>'index')); ?>">Danh mục Tin tức</a> </li>
    </ul>
    <div class="clr"></div>
  </div>
  <div class="b">
    <div class="b">
      <div class="b"></div>
    </div>
  </div>
</div>
<div id="element-box">
  <div class="t">
    <div class="t">
      <div class="t"></div>
    </div>
  </div>
  <div class="m">
<script language="javascript" type="text/javascript">
        $(document).ready(function(){
                 $('#img_132_99').Jcrop({
                    onChange: showCoords_132_99,
                    setSelect: [0,0, 132, 99]
                 });
             

                 $('#img_365_280').Jcrop({
                    onChange: showCoords_365_280,
                    setSelect: [0,0, 365, 280]
                 });
                 $('#img_88_58').Jcrop({
                    onChange: showCoords_88_58,
                    setSelect: [0,0, 88, 58]
                 });
        });
        function showCoords_365_280(c){
            $('#crop_image_monitor').html('width:'+ c.w + ',height:' +  c.h);
            $('#img_365_280_sx').val(c.x);
            $('#img_365_280_sy').val(c.y);
            $('#img_365_280_ex').val(c.x2);
            $('#img_365_280_ey').val(c.y2);

        }
        function showCoords_88_58(c){
            $('#crop_image_monitor').html('width:'+ c.w + ',height:' +  c.h);
            $('#img_88_58_sx').val(c.x);
            $('#img_88_58_sy').val(c.y);
            $('#img_88_58_ex').val(c.x2);
            $('#img_88_58_ey').val(c.y2);
        }
        function showCoords_132_99(c){
            $('#crop_image_monitor').html('width:'+ c.w + ',height:' +  c.h);
            $('#img_132_99_sx').val(c.x);
            $('#img_132_99_sy').val(c.y);
            $('#img_132_99_ex').val(c.x2);
            $('#img_132_99_ey').val(c.y2);
        }
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
                        if($('#NewsTitle').val() == ''){
                            h3l_show_alert($('#NewsTitle'), 'Vui lòng nhập title');
                            $('#NewsTitle').focus();
                            return;
                        }
                        if($('#NewsShortContent').val() == ''){
                            h3l_show_alert($('#NewsShortContent'), 'Vui lòng nhập ghi chú');
                            $('#NewsShortContent').focus();
                            return;
                        }
                submitform( pressbutton );
	}
</script>
    <?php echo $this->Form->create('News', array('type'=>'file', 'style'=> 'clear: both;', 'name'=>'adminForm', 'id'=>'adminForm')); ?>
      <div class="col">
        <fieldset class="adminform">
        <legend>User Details</legend>
        <table cellspacing="1" class="admintable">
          <tbody>
            <tr>
              <td width="150" class="key"><label for="title"> title </label>
              </td>
              <td>
                    <?php echo $this->Form->input('title', array('class'=>'inputbox', 'size'=> 40, 'label'=> false)); ?>
              </td>
            </tr>

            <tr>
              <td width="150" class="key"><label for="published"> Published </label>
              </td>
              <td>
                    <?php echo $this->Form->radio('published', array('1'=> 'Yes', 0=>'No'), array('legend'=>false,'default'=> '1')); ?>
              </td>
            </tr>
            <tr>
              <td width="150" class="key"><label for="hot_news">Tin nổi bật </label>
              </td>
              <td>
                    <?php echo $this->Form->radio('hot_news', array('1'=> 'Yes', 0=>'No'), array('legend'=>false,'default'=> '0')); ?>
              </td>
            </tr>
            <tr>
              <td width="150" class="key"><label for="special_news">Tin đặc biệt</label>
              </td>
              <td>
                    <?php echo $this->Form->radio('special_news', array('1'=> 'Yes', 0=>'No'), array('legend'=>false,'default'=> '0')); ?>
              </td>
            </tr>
            <tr>
              <td width="150" class="key"><label for="parent_id"> Danh mục</label>
              </td>
              <td>
                    <?php
                    echo $this->Form->select('cat_id', $cat_list,array('empty'=> false,'secure'=>true));
                    ?>
              </td>
            </tr>

           <tr>
              <td width="150" class="key"><label for="short_content">Ghi Chú: </label>
              </td>
              <td>
                    <?php echo $this->Form->input('short_content', array('class'=>'inputbox', 'cols'=> 80, 'label'=> false, 'type'=>'textarea')); ?>
              </td>
            </tr>
            <?php if($check_thumbnail_exist): ?>
            <tr>
              <td width="150" class="key"><label for="preview">Preview </label>
              </td>
              <td>
                    <?php
                        echo $this->Html->image($image_url . '?rd=' . time(), array('id'=>'img_132_99'));
                    ?>
                    <?php echo $this->Form->input('delete_image', array('type'=>'checkbox', 'class'=>'inputbox', 'label'=> false)); ?>
                    Xóa Hình Này
                    <?php echo $this->Form->input('thumbnail', array('type'=>'hidden', 'name'=>'img_132_99_filename', 'id'=>'img_132_99_filename')); ?>
                    <?php echo $this->Form->input('img_132_99_sx', array('type'=>'hidden','name'=>'img_132_99_sx','id'=>'img_132_99_sx', 'value'=>0)); ?>
                    <?php echo $this->Form->input('img_132_99_sy', array('type'=>'hidden','name'=>'img_132_99_sy','id'=>'img_132_99_sy', 'value'=>0)); ?>
                    <?php echo $this->Form->input('img_132_99_ex', array('type'=>'hidden','name'=>'img_132_99_ex','id'=>'img_132_99_ex', 'value'=>132)); ?>
                    <?php echo $this->Form->input('img_132_99_ey', array('type'=>'hidden','name'=>'img_132_99_ey','id'=>'img_132_99_ey', 'value'=>99)); ?>
              </td>
              
            </tr>
            <?php
                endif;
            ?>
            <tr>
              <td width="150" class="key"><label for="thumbnail">Thumbnail (132x99)</label>
              </td>
              <td>
                    <?php echo $this->Form->input('thumbnail', array('type'=>'file', 'class'=>'inputbox', 'size'=> 40, 'label'=> false)); ?>
              </td>
            </tr>

            <?php if($check_thumbnail_small_exist): ?>
            <tr>
              <td width="150" class="key"><label for="preview">Preview </label>
              </td>
              <td>
                    <?php
                        echo $this->Html->image($image_small_url . '?rd=' . time(), array('id'=>'img_88_58'));
                    ?>
                    <?php echo $this->Form->input('delete_image_small', array('type'=>'checkbox', 'class'=>'inputbox', 'label'=> false)); ?>
                    Xóa Hình Này
                    <?php echo $this->Form->input('thumbnail_small', array('type'=>'hidden', 'name'=>'img_88_58_filename', 'id'=>'img_88_58_filename')); ?>
                    <?php echo $this->Form->input('img_88_58_sx', array('type'=>'hidden','name'=>'img_88_58_sx','id'=>'img_88_58_sx', 'value'=>0)); ?>
                    <?php echo $this->Form->input('img_88_58_sy', array('type'=>'hidden','name'=>'img_88_58_sy','id'=>'img_88_58_sy', 'value'=>0)); ?>
                    <?php echo $this->Form->input('img_88_58_ex', array('type'=>'hidden','name'=>'img_88_58_ex','id'=>'img_88_58_ex', 'value'=>88)); ?>
                    <?php echo $this->Form->input('img_88_58_ey', array('type'=>'hidden','name'=>'img_88_58_ey','id'=>'img_88_58_ey', 'value'=>58)); ?>
              </td>

            </tr>
            <?php
                endif;
            ?>
            <tr>
              <td width="150" class="key"><label for="thumbnail_small">Thumbnail nhỏ (88x58)</label>
              </td>
              <td>
                    <?php echo $this->Form->input('thumbnail_small', array('type'=>'file', 'class'=>'inputbox', 'size'=> 40, 'label'=> false)); ?>
              </td>
            </tr>

            <?php if($check_thumbnail_slideshow_exist): ?>
            <tr>
              <td width="150" class="key"><label for="preview">Preview </label>
              </td>
              <td>
                    <?php
                        echo $this->Html->image($image_slideshow_url . '?rd=' . time(), array('id'=>'img_365_280'));
                    ?>
                    <?php echo $this->Form->input('delete_image_large', array('type'=>'checkbox', 'class'=>'inputbox', 'label'=> false)); ?>
                    Xóa Hình Này
                    <?php echo $this->Form->input('thumbnail_slideshow', array('type'=>'hidden', 'name'=>'img_365_280_filename', 'id'=>'img_365_280_filename')); ?>
                    <?php echo $this->Form->input('img_365_280_sx', array('type'=>'hidden','name'=>'img_365_280_sx','id'=>'img_365_280_sx', 'value'=>0)); ?>
                    <?php echo $this->Form->input('img_365_280_sy', array('type'=>'hidden','name'=>'img_365_280_sy','id'=>'img_365_280_sy', 'value'=>0)); ?>
                    <?php echo $this->Form->input('img_365_280_ex', array('type'=>'hidden','name'=>'img_365_280_ex','id'=>'img_365_280_ex', 'value'=>365)); ?>
                    <?php echo $this->Form->input('img_365_280_ey', array('type'=>'hidden','name'=>'img_365_280_ey','id'=>'img_365_280_ey', 'value'=>280)); ?>
              </td>

            </tr>
            <?php
                endif;
            ?>
            <tr>
              <td width="150" class="key"><label for="thumbnail_slideshow">Thumbnail lớn (365x280)</label>
              </td>
              <td>
                    <?php echo $this->Form->input('thumbnail_slideshow', array('type'=>'file', 'class'=>'inputbox', 'size'=> 40, 'label'=> false)); ?>
              </td>
            </tr>


            <tr>
              <td class="key"><label for="content">Content </label>
              </td>
              <td>
                    <?php echo $this->Editor->loadEditor('data[News][content]', $content); ?>
              </td>
            </tr>
          </tbody>
        </table>
        </fieldset>
      </div>
      <div class="clr"></div>
      <?php echo $this->Form->input('id', array('type'=>'hidden')); ?>
      <input type="hidden" name="task" value="" />
    </form>
    <div class="clr"></div>
  </div>
  <div class="b">
    <div class="b">
      <div class="b"></div>
    </div>
  </div>
</div>
